package com.zhny.protocol_v3_008.constant;

public enum PTypeCode {
    REGISTER("注册",101),
    HEART ("心跳",102),
    TELEMETRY("遥测",103),
    CONTROL("遥控",104),
    QUERY("查询",105),
    STATE("查询",106),
    REPLY("应答",123),
    ADD_DEV("添加设备",151),
    DEL_DEV("删除设备",152),
    DATA_REPORT("数据填报", 153),
    PLATFORM_REMOTE_CONTROL("平台遥控",154),
    BASE_REMOTE_CONTROL("基地遥控",155);

    private String name;
    private int code;

    private PTypeCode(String name, int code) {
        this.name = name;
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public int getCode() {
        return code;
    }

    public static String getName(int code) {
        if(code == 201) return "响应成功";
        for(PTypeCode rc : PTypeCode.values()) {
            if(rc.code == code)
                return rc.getName();
        }
        return null;
    }
}
